﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace _00_WPF基础.控件
{
	/// <summary>
	/// A24_ProgressBar.xaml 的交互逻辑
	/// </summary>
	public partial class A24_ProgressBar : Window
	{
		public A24_ProgressBar()
		{
			InitializeComponent();
		}

		private void b1_Click(object sender, RoutedEventArgs e)
		{
			double max = pb.Maximum;
			Task.Run(() =>
			{
				for (int i = 0; i < max+1; i++)
				{
					Thread.Sleep(100);
					pb.Dispatcher.Invoke(() =>
					{
						pb.Value = i;
					});
				}
			});
		}

		private void pb_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
		{
			//pb.Dispatcher.Invoke(() =>
			//{
			//	pb.Value = i;
			//});
		}
	}
}
